#!/bin/bash
###############################################################################
# @用例ID: 20220410-152859-724647329
# @用例名称: test_shell_testcase
# @用例级别: 3
# @用例标签:
# @用例类型: 功能
###############################################################################
[ -z "$TST_TS_TOPDIR" ] && {
    TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")"
    export TST_TS_TOPDIR
}
source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1
###############################################################################

g_tmpdir="$(mktemp -d)"

tc_setup() {
    msg "this is tc_setup"
    #安装了mongodb6.0.6
    #安装了openssl1.1.1
    return 0
}

do_test() {
    msg "this is do_test"
    # @测试步骤:1: 克隆mongo
    git clone https://github.com/mongodb/mongo.git
    git checkout r6.0.6
    # @测试步骤:2: 编译单元测试
    rm mongo/SConstruct
    rm mongo/src/mongo/dbtests/SConscript
    mv SConstruct mongo/
    mv SConscript mongo/src/mongo/dbtests/
    cd mongo
    python3 -m pip install -r etc/pip/compile-requirements.txt
    #编译单元测试
    scons -Q install-unittests -disable-warnings-as-errors
    # @测试步骤:3: 编译 dbtest
    scons -Q  -disable-warnings-as-errors
    #javaScript test
    python buildscripts/resmoke.py run jstests/core/find2.js jstests/core/basic1.js
    # @测试步骤:4: 运行单元测试
    # @预期结果:4: 运行成功
    python buildscripts/resmoke.py run --suites=dbtest
    #python buildscripts/resmoke.py run --suites=unittests
    ./build/install/bin/executor_stats_test
    ./build/install/bin/executor_test
    ./build/install/bin/s_test
    ./build/install/bin/scripting_test
    ./build/install/bin/stdx_test
    ./build/install/bin/stitch_support_test
    ./build/install/bin/stitch_support_test
    ./build/install/bin/topology_listener_test
    ./build/install/bin/topology_manager_test

    return 0
}

tc_teardown() {
    msg "this is tc_teardown"
    rm -rfv "$g_tmpdir" || return 1
    return 0
}

###############################################################################
tst_main "$@"
###############################################################################
